package com.itheima.exceptionhandler;

import com.itheima.domain.vo.Result;
import com.itheima.exception.CustomerException;
import com.itheima.exception.DeleteClazzException;
import com.itheima.exception.StudentNoPhoneIdCardException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Author:篍
 * @Date: 2025/07/14 15:30
 * @Description:
 */
@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

    @ExceptionHandler
    public Result deleteClazzExceptionHandler(DeleteClazzException deleteClazzException){
        return Result.error(deleteClazzException.getMessage());
    }

    /**
     * 处理学号，身份证号，手机号重复异常
     * @param studentNoPhoneIdCardException
     * @return
     */
    @ExceptionHandler
    public Result studentNoPhoneIdCardExceptionExceptionHandler(StudentNoPhoneIdCardException studentNoPhoneIdCardException){
        return Result.error(studentNoPhoneIdCardException.getMessage());
    }

    @ExceptionHandler
    public Result repeat(CustomerException customerException ){
        return Result.error(customerException.getMessage());
    }
}
